SOAPMethod Class

Used to call a SOAP remote method or function.

Events

None

Properties

Action

MethodNamespace

Parameter

Timeout

URL

WSDL


Methods

ClearParameters

Invoke

LoadWSDLFromURL

UseSocket


More information available in parent classes: Object


Constructor

NameParametersDescription
SOAPMethod [URL as String] Creates a SOAPMethod object, optionally with the URL to the WSDL document. Otherwise, set the URL and WSDL using the URL and WSDL properties.


Notes

To execute a SOAP service, a WSDL must be set in order to pass the correct parameter values. For example, if the SOAP service provides a function called GetTemp, which takes a Zip Code, you call it as follows:

SOAPMethod1.GetTemp("60615")

Examples

The following example creates a SOAPMethod and loads its WSDL from the URL specified in the constructor. It assumes that a valid Zip Code has been entered into an EditField called ZipCodeFld. It then calls the GetTemp function and displays the result.

Dim sm as SOAPMethod

sm = New SOAPMethod("http://www.xmethods.net/sd/2001/TemperatureService.wsdl")
MsgBox sm.GetTemp(zipcodeFld.text)

The following example gets information about a Zip Code. It uses the Result function of the SOAPResult class to look for a particular tag within the result for easy data retrieval.

Dim sm as SoapMethod
Dim sr as SOAPResult
// create the soap method and set the parameter(s)
sm = New SoapMethod
sm.parameter("USZip") = zipcodeFld.text

// set soap method properties
sm.methodNamespace = "http://www.webserviceX.NET"
sm.action = "http://www.webserviceX.NET/GetInfoByZIP"
sm.url = "http://www.webserviceX.NET/uszip.asmx"

// execute the method
sr = sm.invoke("GetInfoByZIP")

// display the Area_Code portion of the result
MsgBox sr.result("Area_Code")

The following example will generate an error from the SOAP service because the method namespace is incorrect. A "B" has been appended to the end of it. The SOAPResult class will provide the error information received from the SOAP service.

Dim sm as SoapMethod
Dim sr as SOAPResult
// create SOAPMethod and define parameters
sm = New SoapMethod
//Assume there's an EditField named emailFld in the window
sm.parameter("EmailAddress") = emailFld.text

// set method properties
sm.methodNamespace = "http://www.webserviceX.NETB" //incorrect
sm.action = "http://www.webserviceX.NET/IsValidEMail"
sm.url = "http://www.webserviceX.NET/ValidateEmail.asmx"
// execute function
sr = sm.invoke("IsValidEMail")

// check for error
If sr.error = True then
  Beep
  MsgBox "ERROR: " + sr.errorMessage
else
 // display result
  MsgBox sr.result("IsValidEMailResult")
end

See Also

SOAPResult class; SOAPException error.